/*    */ package com.zimbra.cs.account;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public abstract class MailTarget
/*    */   extends NamedEntry
/*    */ {
/*    */   protected String mDomain;
/*    */   protected String mUnicodeDomain;
/*    */   protected String mUnicodeName;
/*    */   private static final String NO_DOMAIN_ID = "";
/*    */   
/*    */   public MailTarget(String name, String id, Map<String, Object> attrs, Map<String, Object> defaults, Provisioning prov)
/*    */   {
/* 35 */     super(name, id, attrs, defaults, prov);
/* 36 */     int index = name.indexOf('@');
/* 37 */     if (index != -1) {
/* 38 */       String local = name.substring(0, index);
/* 39 */       this.mDomain = name.substring(index + 1);
/* 40 */       this.mUnicodeDomain = IDNUtil.toUnicodeDomainName(this.mDomain);
/* 41 */       this.mUnicodeName = (local + "@" + this.mUnicodeDomain);
/*    */     } else {
/* 43 */       this.mUnicodeName = name;
/*    */     }
/*    */   }
/*    */   
/*    */ 
/*    */   public String getDomainName()
/*    */   {
/* 50 */     return this.mDomain;
/*    */   }
/*    */   
/*    */   public String getUnicodeDomainName() {
/* 54 */     return this.mUnicodeDomain;
/*    */   }
/*    */   
/*    */   public String getUnicodeName() {
/* 58 */     return this.mUnicodeName;
/*    */   }
/*    */   
/*    */   public String getDomainId() {
/* 62 */     String domainId = (String)getCachedData(EntryCacheDataKey.MAILTARGET_DOMAIN_ID);
/*    */     
/* 64 */     if (domainId == null) {
/*    */       try {
/* 66 */         String dname = getDomainName();
/* 67 */         Provisioning prov = getProvisioning();
/* 68 */         Domain domain = prov == null ? null : dname == null ? null : prov.get(Key.DomainBy.name, dname);
/* 69 */         if (domain != null)
/* 70 */           domainId = domain.getId();
/*    */       } catch (ServiceException e) {
/* 72 */         ZimbraLog.account.warn("unable to get domain id for domain " + getDomainName(), e);
/*    */       }
/*    */       
/* 75 */       if (domainId == null) {
/* 76 */         domainId = "";
/*    */       }
/* 78 */       setCachedData(EntryCacheDataKey.MAILTARGET_DOMAIN_ID, domainId);
/*    */     }
/*    */     
/*    */ 
/* 82 */     if (domainId == "") {
/* 83 */       return null;
/*    */     }
/* 85 */     return domainId;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/MailTarget.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */